home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / lib / glut / glut_bwidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  1.0 KB  |  48 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <GL/glut.h>
  9. #include "glutint.h"
  10. #include "glutbitmap.h"
  11.  
  12. /* CENTRY */
  13. int
  14. glutBitmapWidth(GLUTbitmapFont font, int c)
  15. {
  16.   BitmapFontPtr fontinfo = (BitmapFontPtr) font;
  17.   BitmapCharPtr ch;
  18.  
  19.   if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
  20.     return 0;
  21.   ch = fontinfo->ch[c - fontinfo->first];
  22.   if (ch)
  23.     return ch->advance;
  24.   else
  25.     return 0;
  26. }
  27.  
  28. int
  29. glutBitmapLength(GLUTbitmapFont font, unsigned char *string)
  30. {
  31.   int c, length;
  32.   BitmapFontPtr fontinfo = (BitmapFontPtr) font;
  33.   BitmapCharPtr ch;
  34.  
  35.   length = 0;
  36.   for (; *string != '\0'; string++) {
  37.     c = *string;
  38.     if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars) {
  39.       ch = fontinfo->ch[c - fontinfo->first];
  40.       if (ch)
  41.     length += ch->advance;
  42.     }
  43.   }
  44.   return length;
  45. }
  46.  
  47. /* ENDCENTRY */
  48.